;--------------------------------------
;
; prog4-5.asm
;
; Demonstration of 
;   strcmp

;--------------------------------------
;
; include all defines, macros, 
; prototypes and set up memory model
;

include tab6.inc


;--------------------------------------
;
; Create stack
;

	.STACK                         ; 1 k by default

;--------------------------------------
;
; Declare data segment
;

	.DATA


str1	db	'Baxter W. D. Dorfman',0
str2	db	'Chuck Dorfman       ',0
str3	db	'Barbara J. Dorfman  ',0
dummy 	db  '                    ',0

attr1	db	?

;--------------------------------------
;
; Begin code segment
;

	.CODE


;--------------------------------------
;
; Start program here
;

	.STARTUP


;--------------------------------------
;

	INVOKE	vidInit

;--------------------------------------
;
; make the attributes
;

	INVOKE mkAttr,ADDR attr1,WHITE,MAGENTA,OFF_INTENSITY,OFF_BLINK

;--------------------------------------
;
; clear the screen via bios with the
; attr1
;

	INVOKE  clrScrn,NORMAL

;--------------------------------------
; write program messages 


	INVOKE	vdWrite,1,0,0,ADDR str1,attr1

	INVOKE	vdWrite,2,0,0,ADDR str2,attr1

	INVOKE	vdWrite,3,0,0,ADDR str3,attr1

;--------------------------------------
;
; sort strs
;

; compare str1 and str2

	INVOKE	strcmp,ADDR str2,ADDR str1 ; compare str1 and str2

	.IF (return_value==1)          ; if str1 > str2 then switch
	INVOKE	strcpy,ADDR dummy,ADDR str1
	INVOKE	strcpy,ADDR str1,ADDR str2
	INVOKE	strcpy,ADDR str2,ADDR dummy
	.ENDIF

; compare str2 and str3

	INVOKE	strcmp,ADDR str3,ADDR str2  ; compare str2 and str3

	.IF (return_value==1)          ; if str2 > str3 then switch
	INVOKE	strcpy,ADDR dummy,ADDR str2
	INVOKE	strcpy,ADDR str2,ADDR str3
	INVOKE	strcpy,ADDR str3,ADDR dummy
	.ENDIF


; compare str1 and str2

	INVOKE	strcmp,ADDR str2,ADDR str1 ; compare str1 and str2

	.IF (return_value==1)           ; if str1 > str2 then switch
	INVOKE	strcpy,ADDR dummy,ADDR str1
	INVOKE	strcpy,ADDR str1,ADDR str2
	INVOKE	strcpy,ADDR str2,ADDR dummy
	.ENDIF


;--------------------------------------
; write program messages 


	INVOKE	vdWrite,5,0,0,ADDR str1,attr1

	INVOKE	vdWrite,6,0,0,ADDR str2,attr1

	INVOKE	vdWrite,7,0,0,ADDR str3,attr1

;--------------------------------------
;
; move the cursor to 8,0
;

	INVOKE	mvCur,8,0

;--------------------------------------
;
; End program and return to DOS
;

	.EXIT

;--------------------------------------
;
; End of ASSEMBLY source file
;

	END

;
;--------------------------------------
